$m(function(){
	var grid = $("#tempo_webapi_grid"),
		that = this,
		$this = this.element;   
	
	var locale = function(l){
		return TempoUtils.locale("webapi."+l);
	}
	
	function renderGrid(){
		grid.datagrid({
			url : contextPath+"/api/view/getApis",
			datatype : 'json',
			fit:true,
			rownumbers : true,
			multiselect : false, 
			rowNum : 20,
			rowList : [ 10, 20, 30 ],
			pagination : true,
			viewrecords : true,
			striped:true,
			separator:false, 
			colNames:['apiId', locale("api_name"), locale("api_url"), locale("api_type"), 'inparam', 'outparam', 'desc',locale("operation")],
			colModel:[{
				name:'apiId',
				hidden:true
			},{
				name:'name',
				sortable:false
			},{
				name:'url',
				sortable:false, 
				align: 'center',
				formatter:function(d){
					return '-'; 
				}
			},{
				name:'type',
				sortable:false, 
				align: 'center',
				formatter:function(d){
					return '-'; 
				}
			},{
				name:'inParam',
				hidden:true
			},{
				name:'outParam',
				hidden:true
			},{
				name:'desc',
				hidden:true
			},{
				name:'action',
				buttons:[{
					id:"view",
					title:locale("api_info_title"),
					icon:"ui-icon tempo-ui-icon tempo-ui-icon-edit",
					click:function(e,dt){
						preViewApi(dt.rowData);
					}
				}]
			}],
			postData:{
				appId : "ai"
			}
		});
		 
	}
	
	function preViewApi(rowdata){
		rowdata.url = contextPath + rowdata.url;
		$m.loadHtml(contextPath+"/api/view/webapiDialog",$("body"),"tempo-webapi-dialog",{
			fillback:rowdata
		}); 
	}
	
	//初始化
	(function(){ 
		renderGrid(); 
	}());
});